Home / Data table / Search data

Data table ‐ Search data


API calls to get data from selected data tables

Endpoint

GET /api/datatable/search/:dataTable/:fieldName/:fieldValue[/:page][/columns/:columnsToShow]

Parameters:

  • :dataTable (string) - name of the table within which the search is done
  • :fieldName (string) - name of the column by which the search is done
  • :fieldValue (mixed) - value by which the search is done, search is done by full values only (so, one cannot use, for example, for e-mails that "starts with...")
  • :page (integer) - OPTIONAL, default 1, which page of results show
  • :columnsToShow (string[]) - OPTIONAL, JSON-encoded array of column names which should be shown in the result set, by default all columns are shown

Headers

see Using authentication token

Response

  • Invalid response: See Invalid response in Standard response rules
  • Valid response
    Valid response contains following properties:
    • valid - set to true
    • data (Object[]) - list of found rows (in form of JSON objects)
    • pagination - info about pagination with following info:
      • has_next_page (boolean) - is there a next page or not
      • next_page (integer) - only present if has_next_page has value true, says what's the number of the next page
      • rows_per_page (integer) - how many rows per page are shown

        {
            "valid": true,
            "data": [
                {
                    "id": "3",
                    "client_id": "1",
                    "name": "Test"
                } 
            ],
            "pagination": {
                "is_next_page": true,
                "next_page": 2,
                "rows_per_page": 1
            } 
        }

Example code:

<?php

require_once 'RestOpen.php';

$username = 'my_username';
$password = 'my_password';
$workspaceId = 999;
$tableName = 'your_table_name';
$searchColumn = 'your_column_to_search';
$searchValue = 'value_to_search';
$page = 0;
$columnsToReturn = array('column_name_1', 'column_name_2');

$rest = new RestOpen($username, $password, $workspaceId);
$result = $rest->getDataTableSearch($tableName,$searchColumn, $searchValue, $page, $columnsToReturn);

var_dump($result);